$(document).ready(function(){
	$('#login').click(function(){
		var system ={
		win : false,
		mac : false,
		xll : false
		};
		//检测平台
		var p = navigator.platform;
				
		var login_infor;//当前浏览器
		system.win = p.indexOf("Win") == 0;
		system.mac = p.indexOf("Mac") == 0;
		system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
		if(system.win||system.mac||system.xll){
		  var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串

		   var Opera = userAgent.indexOf("OPR") > -1; //判断是否Opera浏览器

		   var IE = userAgent.indexOf(".NET") > -1; //判断是否IE的Edge浏览器
		   var Firefox = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
		   var Safari = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器
		   var Chrome = userAgent.indexOf("Chrome") > -1 && userAgent.indexOf("Safari") > -1; //判断Chrome浏览器
		   var Edge= userAgent.indexOf("Edge") > -1 ; //判断是否IE浏览器
		   Opera?login_infor='Opera':0;
		   IE?login_infor='IE':0;

		   Firefox?login_infor='Firefox':0;
		   Safari?login_infor='Safari':0;
		   Chrome?login_infor='Chrome':0;
		   Edge?login_infor='Edge':0;
		   console.log(login_infor)
  
		}else{
			var appVersion = navigator.appVersion;
			if(appVersion.indexOf('iPhone')>-1){
				login_infor = 'iPhone';
			}else{
				login_infor = 'Android'
			}
		}
				
		$.ajax({
				type:"get",
				headers: {
					Accept: "application/json; charset=utf-8"
				},
				url:"http://114.116.72.220:9999/LoginManage/",
				data:{
                    userName:$('#account').val(),
                    userPassword:$('#password').val(),
				},
				success:function(data){
					if(data[0]=='success'){
						$.cookie('UserId',data[1][0],{expires:1});
						$.cookie('UserRight',data[1][1],{expires:1});

						layer.msg('登录成功',{time:500},function(){
							if(data[1][1]==4){
								$.cookie('UserRightText','订单管理员',{expires:1});
								window.location.href='http://114.116.72.220:9010/src/hire_order.html';
						 	}else if(data[1][1]==3){
							 	$.cookie('UserRightText','商品管理员',{expires:1});
							 	window.location.href='http://114.116.72.220:9010/src/product_list.html';
						 	}else if(data[1][1]==2){
							  	$.cookie('UserRightText','普通管理员',{expires:1});
							  	window.location.href='http://114.116.72.220:9010/src/product_list.html';
						 	}else{
							 	$.cookie('UserRightText','高级管理员',{expires:1});
							 	window.location.href='http://114.116.72.220:9010/src/product_list.html';
							}
					 	 })
					}else{
						layer.msg('登录失败，账号或密码错误');
					}
						
				}
			});
	});
});